package com.lzb.browser.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.browser.R;
import com.lzb.browser.basic.ProviderMultiAdapter;
import com.lzb.browser.bean.HomeBean;
import com.lzb.browser.bean.SearchSuggestionBean;

public class SearchSuggestionAdapter extends ProviderMultiAdapter<SearchSuggestionBean> {

    public SearchSuggestionAdapter() {
        addItemProvider(new SearchSuggestionProvider());
    }

    private class SearchSuggestionProvider extends BaseItemProvider<SearchSuggestionBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_search_suggestion;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SearchSuggestionBean bean) {
            baseViewHolder.setText(R.id.tvSearchSuggestionItemTitle, bean.getTitle());
            if (bean.isRecord()) {
                baseViewHolder.getView(R.id.tvSearchSuggestionItemUrl).setVisibility(View.VISIBLE);
                baseViewHolder.setImageResource(R.id.ivSearchSuggestionItemImg, R.drawable.jilu);
                baseViewHolder.setText(R.id.tvSearchSuggestionItemUrl, bean.getUrl());
            } else {
                baseViewHolder.getView(R.id.tvSearchSuggestionItemUrl).setVisibility(View.GONE);
                baseViewHolder.setImageResource(R.id.ivSearchSuggestionItemImg, R.drawable.sousuo);
            }
        }
    }

}
